<?php
/**
 * SocialEngine
 *
 * @category   Application_Extensions
 * @package    Page
 * @copyright  Copyright Hire-Experts LLC
 * @license    http://www.hire-experts.com
 * @version    $Id: AdminSettingsController.php 2010-08-31 16:05 idris $
 * @author     Idris
 */

/**
 * @category   Application_Extensions
 * @package    Page
 * @copyright  Copyright Hire-Experts LLC
 * @license    http://www.hire-experts.com
 */

class Page_AdminSettingsController extends Core_Controller_Action_Admin {
	public function init() {
		$this->view->navigation = $navigation = Engine_Api::_ ()->getApi ( 'menus', 'core' )->getNavigation ( 'page_admin_main', array (), 'page_admin_main_settings' );
	}
	
	public function indexAction() {
		$this->view->form = $form = new Page_Form_Admin_Global ();
		$settings = Engine_Api::_ ()->getApi ( 'settings', 'core' );
		
		if (! $this->getRequest ()->isPost ()) {
			return;
		}
		
		if (! $form->isValid ( $this->getRequest ()->getPost () )) {
			return;
		}
		
		// Check license
		/* Nulled By Hazaraboy
    $hecoreApi = Engine_Api::_()->getApi('core', 'hecore');
    $product_result = $hecoreApi->checkProduct('pages');
    
    if (isset($product_result['result']) && !$product_result['result']) {
      $form->addError($product_result['message']);
      $this->view->headScript()->appendScript($product_result['script']);
    
      return;
    }
  	*/
		$value = $form->getValue ( 'gmap_key' );
		$settings->setSetting ( 'page.gmapkey', $value );
		$form->gmap_key->setValue ( $value );
		
		$value = $form->getValue ( 'browse_page_count' );
		$settings->setSetting ( 'page.browse_count', $value );
		$form->browse_page_count->setValue ( $value );
		
		$value = $form->getValue ( 'recent_page_count' );
		$settings->setSetting ( 'page.recent_count', $value );
		$form->recent_page_count->setValue ( $value );
		
		$value = $form->getValue ( 'popular_page_count' );
		$settings->setSetting ( 'page.popular_count', $value );
		$form->popular_page_count->setValue ( $value );
		
		$value = $form->getValue ( 'featured_page_count' );
		$settings->setSetting ( 'page.featured_count', $value );
		$form->featured_page_count->setValue ( $value );
		
		$value = $form->getValue ( 'approval' );
		$settings->setSetting ( 'page.approval', $value );
		$form->approval->setValue ( $value );
	}
}